#!/usr/bin/env python3
# _*_coding:utf-8 _*_
__author__ = "Gao"
'''定制序列化'''
import json
from django.forms import ValidationError

class JsonCustomEncoder(json.JSONEncoder):
    # 定制序列化
    def default(self, field):
        if isinstance(field, ValidationError):
            return {'code': field.code, 'messages': field.messages}